import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
  ],
  server: {
    port: 8081,
    host: true,
    open: '/login',
    proxy: {
      '/api': {
        target: "http://localhost:8083", //代理请求baseurl
        changeOrigin: true,  //允许跨域
        //路径重写
        rewrite: path => path.replace(/^\/api/, '') // 重写 api 为 空，就是去掉它
      },
      '/image': {
        target: "http://localhost:8083",
        changeOrigin: true
      },
    }
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
